package com.yiqiu.common.core.handler;

import com.yiqiu.common.core.domain.vo.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * 全局异常处理器
 * @author weiyi
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    @ExceptionHandler(Exception.class)
    public AjaxResult globalException(Exception e) {
        logger.error(e.getMessage(), e);
        return AjaxResult.error("服务器内部错误,请联系管理员");
    }

}
